﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Student : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie loginUser = Request.Cookies.Get("LoginUser");

        if (Session["userName"] == null || Session["userType"] == null || Session["userType"].ToString() != "SinhVien")
        {
            Response.Redirect("~/Default.aspx");
        }
        else
        {
            string MSSV = Session["userName"].ToString();
            SqlConnection conn = new SqlConnection(connectionString);
            SqlDataAdapter dataAdapter = new SqlDataAdapter("Select TenMH,MonHoc.MaMH,GiangVien.MSGV,HoTen,HocKy from DangKy,MonHoc,GiangVien Where DangKy.MaMH=MonHoc.MaMH and DangKy.MSGV=GiangVien.MSGV and MSSV ='" + MSSV + "'", conn);
            DataTable dataTable = new DataTable();
            dataAdapter.Fill(dataTable);
            GridView1.DataSource = dataTable;
            GridView1.DataBind();
        }
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int i = Convert.ToInt32(e.CommandArgument);
        string MSGV = GridView1.Rows[i].Cells[3].Text.ToString();
        string MaMH = GridView1.Rows[i].Cells[1].Text.ToString();
        string HocKy = GridView1.Rows[i].Cells[5].Text.ToString();
        Response.Redirect("Student_1.aspx?&MSGV=" + MSGV.ToString() + "&MaMH=" + MaMH.ToString() + "&HocKy=" + HocKy.ToString());

    }
    
    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
        Logout();
    }
}